package com.dhh.sky.service;

import com.dhh.sky.model.Operation;
import com.dhh.sky.util.Constant;
import com.dhh.sky.util.FileManager;
import com.dhh.sky.util.OperationManager;
import com.microsoft.live.LiveConnectClient;
import android.content.Intent;
import android.util.Log;

public abstract class BasicOperationService extends BaseService {
	protected OperationManager oManager;
	protected FileManager fManager;
	protected LiveConnectClient mClient;
	protected String path;
	protected String message;
	protected Operation op;
	
	public BasicOperationService(String name) {
		super(name);
	}
	
	protected void response(boolean isDone, String message, String path) {
		Intent respone = new Intent(Constant.SERVICE_NAME_BASIC);
		respone.putExtra(Constant.SERVICE_PARAM_ID, path);
		respone.putExtra(Constant.SERVICE_PARAM_DONE, isDone);
		respone.putExtra(Constant.SERVICE_PARAM_MSG, message);
		sendBroadcast(respone);
		Log.d(Constant.TAG, "response(): "+isDone);
	}
	
	public void process(Intent intent){
		try{
	        oManager = new OperationManager(getBaseContext());
	        fManager = new FileManager(getBaseContext());	
	        doOperation(intent);
		}catch(Exception e){
			Log.e(Constant.TAG, e.getMessage(), e);
		}		
	}
	
	protected abstract void doOperation(Intent intent);
}
